记一次thinkphp6(TP6)安装的坑。 |
您所在的位置:网站首页 › tp6 service › 记一次thinkphp6(TP6)安装的坑。 |
环境要求
PHP >= 7.1.0
Composer(没安装的可以先去安装 https://www.phpcomposer.com/)
)
tp6之后,只支持composer方式安装了,稍微熟悉一下就好了,包管理工具都是大同小异
安装tp6
先切换到自己的web目录下,执行: composer create-project topthink/think tp 这里的tp目录名你可以任意更改,这个目录就是应用根目录。 版本更新如果之前有安装过,需要更新到最新版,就切换到应用根目录(不要搞混了)执行下面的命令更新: composer update topthink/framework 更新操作会删除thinkphp目录重新下载安装新版本,但不会影响app目录,因此不要在核心框架目录添加任何应用代码和类库。 开启调试模式应用默认是部署模式,在开发阶段,可以修改环境变量APP_DEBUG开启调试模式,上线部署后切换到部署模式。 本地开发的时候可以在应用根目录下面定义.env文件。 通过create-project安装后在根目录会自带一个.example.env文件(环境变量示例),你可以直接更名为.env文件并根据你的要求进行修改,该示例文件已经开启调试模式 测试运行应用根目录下运行 php think run 浏览器中输入: http://localhost:8000/ 看到欢迎页表示安装成功。 也可以使用指定的80端口: php think run -p 80 坑来了!!! 执行php think run的时候报错。 PHP Warning: require(F:\code\tp/vendor/autoload.php): failed to open stream: No such file or directory in F:\code\tp\think on line 7 Warning: require(F:\code\tp/vendor/autoload.php): failed to open stream: No such file or directory in F:\code\tp\think on line 7 PHP Warning: require(F:\code\tp/vendor/autoload.php): failed to open stream: No such file or directory in F:\code\tp\think on line 7 Warning: require(F:\code\tp/vendor/autoload.php): failed to open stream: No such file or directory in F:\code\tp\think on line 7 PHP Fatal error: require(): Failed opening required 'F:\code\tp/vendor/autoload.php' (include_path='.;C:\php\pear') in F:\code\tp\think on line 7 Fatal error: require(): Failed opening required 'F:\code\tp/vendor/autoload.php' (include_path='.;C:\php\pear') in F:\code\tp\think on line 7根据报错得知,vendor目录下为空,应该是依赖没有安装好,所以执行 php composer.phar install 安装依赖,但是事实并没又想我想的那样,安装又报错了。 Could not open input file: composer.phar查阅资料得知,这个和php的一个配置有关,打开php.ini文件,找到extension=php_openssl.dll,发现前面本来就没有分号,遂用: php C:\composer\composer.phar install 然后,又得到了报错(真是一波三折啊)。 PHP Warning: putenv() has been disabled for security reasons in phar://C:/composer/composer.phar/vendor/composer/xdebug-handler/src/Process.php on line 149 Warning: putenv() has been disabled for security reasons in phar://C:/composer/composer.phar/vendor/composer/xdebug-handler/src/Process.php on line 149 PHP Warning: putenv() has been disabled for security reasons in phar://C:/composer/composer.phar/bin/composer on line 57 Warning: putenv() has been disabled for security reasons in phar://C:/composer/composer.phar/bin/composer on line 57 [ErrorException] putenv() has been disabled for security reasons根据报错得知,原来是putenv这个函数被PHP关闭了,所以继续打开php.ini文件,找到disable_functions这一项,删掉putenv。 继续执行php composer.phar install来安装依赖。然后得到了大量的提示文字,其中有一句 The Process class relies on proc_open, which is not available on your PHP installation.说的是Process这个类,依赖于函数proc_open,但是我的php也不支持这函数,所以还需要删掉php.ini中disable_functions中的proc_open。(我去,为什么不一次告诉我)。 后来几次安装,都是报了类似的错误,大概总结了下,需要删掉php.ini中disable_functions中的: proc_open, putenv,proc_get_status,passthru。嫌麻烦直接干掉所有的。 最后再执行 php think run 终于提示: ThinkPHP Development server is started On You can exit with `CTRL-C` Document root is: F:\code\tp\public安装成功了!(太难了) |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |